package com.newjiabo.web.controller.ski;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newjiabo.common.annotation.Log;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.enums.BusinessType;
import com.newjiabo.ski.domain.SkiAssess;
import com.newjiabo.ski.service.ISkiAssessService;
import com.newjiabo.common.utils.poi.ExcelUtil;
import com.newjiabo.common.core.page.TableDataInfo;

/**
 * 评价Controller
 * 
 * @author CaoMengHui
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/ski/assess")
public class SkiAssessController extends BaseController
{
    @Autowired
    private ISkiAssessService skiAssessService;

    /**
     * 查询评价列表
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkiAssess skiAssess)
    {
        startPage();
        List<SkiAssess> list = skiAssessService.selectSkiAssessList(skiAssess);
        return getDataTable(list);
    }

    /**
     * 导出评价列表
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:export')")
    @Log(title = "评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkiAssess skiAssess)
    {
        List<SkiAssess> list = skiAssessService.selectSkiAssessList(skiAssess);
        ExcelUtil<SkiAssess> util = new ExcelUtil<SkiAssess>(SkiAssess.class);
        util.exportExcel(response, list, "评价数据");
    }

    /**
     * 获取评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(skiAssessService.selectSkiAssessById(id));
    }

    /**
     * 新增评价
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:add')")
    @Log(title = "评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkiAssess skiAssess)
    {
        return toAjax(skiAssessService.insertSkiAssess(skiAssess));
    }

    /**
     * 修改评价
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:edit')")
    @Log(title = "评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkiAssess skiAssess)
    {
        return toAjax(skiAssessService.updateSkiAssess(skiAssess));
    }

    /**
     * 删除评价
     */
    @PreAuthorize("@ss.hasPermi('ski:assess:remove')")
    @Log(title = "评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(skiAssessService.deleteSkiAssessByIds(ids));
    }
}
